<template>
	<view class="content">
		<view class="bag" style="background-image: url(https://socialmall.yuntaiqikeji.com/uploads/20230606/66a7d772902d8181b04a09e61e3f690e.png);">
			<view class="header">
				<view class="denglu">欢迎登录</view>
				<input type="number" placeholder="请输入手机号" class="zh" v-model="mobile">
				<view class="header_a flexbetween">
					<!-- <input type="text" placeholder="请输入密码" class="mm" v-model="password"> -->
					<input type="text" :password="eye" placeholder="请输入密码" class="mm" v-model="password">
					<view class="huoqu" @click="sys">
						<image src="/static/image/home/eye.png" mode="" class="img" v-show="eye"></image>
						<image src="/static/image/home/eyes.png" mode="" class="img" v-show="!eye"></image>
					</view>
				</view>
				<view class="word_rb flexbetween black ">
					<view class="margin_top4" @click="shouquan">忘记密码</view>
					<view @click="zhuce" class="margin_top4">立即注册</view>
				</view>
				<view class="yue flexleft" @click="changeclick">
					<image src="/static/image/home/wiexuanzhong.png" mode="" class="dui" v-show="!quan"></image>
					<image src="/static/image/home/xuanzhong.png" mode="" class="dui" v-show="quan"></image>
					<view class=""> 阅读并同意<text class="orange" @click.stop="toyonghuxy">《用户协议》</text>和<text
							class="orange" @click.stop="toyinsi">《隐私保护政策》</text></view>
				</view>
				<view class="dl" @click="thelogin">登录</view>
			</view>
		</view>

	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				quan: false,
				eye: true,
				password: '',
				mobile: '',
				passwordType: "password",
				
			}
		},
		
		methods: {
			
			shouquan() {
				uni.navigateTo({
					url: "/pages/login/wangjimm"
				})
			},
			sys() {
				this.eye = this.eye ? false : true
				// this.passwordType = this.passwordType == "password" ? "text" : "password"
			},
			changeclick() {
				this.quan = this.quan ? false : true
			},
			// changeInput(e){
			// 	setTimeout(()=>{
			// 		this.mobile=e.detail.value
			// 	},1000)
			// },
			// 发送验证码
			sendcode() {
				let _this = this
				let mobile = _this.mobile;
				if (!mobile.match(/^1\d{10}$/)) {
					httpRequest.toast("请输入有效的手机号码");
					return false;
				}
				httpRequest.request('/api/sms/send', 'GET', {
					mobile: mobile,
					event: "mobilelogin"
				}).then(resp => {
					if (resp.code == 1) {
						var i = 60;
						var timer = setInterval(function() {
							_this.codetext = i + "秒";
							if (i < 1) {
								clearInterval(timer);
								_this.codetext = "获取验证码";
							} else {
								i--;
							}
						}, 1000)

					} else if (resp.code == 0) {
						httpRequest.toast(resp.msg);
					} else {
						httpRequest.toast('网络开小差啦');
					}
				})
			},
			thelogin() {
				let _this = this
				let mobile = _this.mobile;
				let password = _this.password
				if (mobile == '') {
					httpRequest.toast('请输入手机号');
					return false;
				}
				if (!mobile.match(/^1\d{10}$/)) {
					httpRequest.toast("请输入有效的手机号码");
					return false;
				}
				if (password == "") {
					httpRequest.toast('请输入密码');
					return false;
				}
				if (!_this.quan) {
					httpRequest.toast('请仔细阅读用户协议并勾选');
					return false;
				}
				httpRequest.request('/api/user/login', 'GET', {
					account: mobile,
					password: password
				}).then(resp => {
					if (resp.code == 1) {
						httpRequest.toast(resp.msg);
						let userinfo = resp['data']['userinfo'];
						// 存
						uni.setStorageSync('token', userinfo['token']);
						uni.setStorageSync('user_id', userinfo['user_id']);
						// uni.setStorageSync('invite_code', userinfo['invite_code']);
						// _this.bindGx()
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
					if (resp.code == 0) {
						httpRequest.toast(resp.msg);
					}
				})
			},
			zhuce() { //跳转到注册页面
				uni.navigateTo({
					url: "/pages/login/lijizc"
				})
			},
			//跳转用户协议
			toyonghuxy() {
				uni.navigateTo({
					url: '/pages_my/yonghuxy'
				})
			},
			//跳转隐私政策
			toyinsi() {
				uni.navigateTo({
					url: '/pages_my/yinsi'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.img {
		width: 28rpx;
		height: 20.36rpx;
	}

	.huoqu {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: RGBA(255, 117, 16, 1);
		margin-right: 14rpx;
		min-width: 200rpx;
		text-align: right;
	}

	.orange {
		color: rgba(212, 139, 57, 1);
	}

	.bag {
		width: 100%;
		height: 100vh;
		background-size: 100% 100%;
	}


	.header_a {
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.10);
	}

	.content {
		background-color: #ffffff;
		min-height: 80vh;
	}

	.header {
		padding: 0rpx 30rpx;
	}

	.denglu {
		padding-top: 208rpx;
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	input:input-placeholder {
		color: #999999;
	}

	.zh {
		flex: 1;
		width: 100%;
		height: 40rpx;
		margin-top: 86rpx;
		padding-bottom: 28rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.10);
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
	}

	.mm {
		flex: 1;
		width: 100%;
		height: 40rpx;
		margin-top: 44rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.10);
		padding-bottom: 45rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
	}

	.yue {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
		margin-top: 71rpx;
		margin-left: 10rpx;
		margin-right: 8rpx;
	}

	.dui {
		width: 26rpx;
		height: 26rpx;
		margin-right: 7rpx;
	}

	.dui1 {
		width: 23rpx;
		height: 23rpx;
		margin-right: 7rpx;
		border: 1rpx solid #999;
		border-radius: 50%;
	}

	.dl {
		margin-left: 10rpx;
		margin-right: 8rpx;
		margin-top: 30rpx;
		width: 672rpx;
		height: 82rpx;
		background-color: rgba(212, 139, 57, 1);
		font-size: 32rpx;
		border-radius: 41rpx 41rpx 41rpx 41rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 82rpx;
		text-align: center;
	}
</style>